package com.it;

import java.util.Random;
import java.util.Scanner;

public class Guessing {
    public static void main(String[] args) {
        int i = new Random().nextInt(100) + 1;//确认随机数1-100以内
        Scanner scanner = new Scanner(System.in);

        while (true) {
            System.out.println("请输入你要猜的数字");
            int num = scanner.nextInt();

            if (num > i) {
                System.out.println("猜的数字大了");
            } else if (num < i) {
                System.out.println("猜的数字小了");
            } else {
                System.out.println("恭喜你猜对了");
                break;
            }
        }
    }
}
